//
//  XMSWaitSync.m
//  etionMisc
//
//  Created by wjxfhxy on 15/9/15.
//  Copyright (c) 2015年 GuangZhouXuanWu. All rights reserved.
//

#import "XMSWaitSync.h"

@implementation XMSWaitSync
{
    dispatch_semaphore_t _semaphore;
}

- (void)dealloc
{
    if (_semaphore != NULL)
        dispatch_release_mm(_semaphore);
    _semaphore = NULL;
    superdealloc_mm;
}

- (void)wait
{
    if (_semaphore == NULL)
        _semaphore = dispatch_semaphore_create(0);
    dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER);
}

- (void)stop
{
    if (_semaphore != NULL)
        dispatch_semaphore_signal(_semaphore);
}

@end
